﻿package mortal.game.view.mainUI.zazen
{
    import Message.Public.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class ZazenInviteicon extends HintBaseIcon
    {
        private var _invitArray:Array;
        private static var _instance:ZazenInviteicon;

        public function ZazenInviteicon()
        {
            this._invitArray = new Array();
            super(ImagesConst.ZazenHintIcon);
            return;
        }// end function

        public function addInfo(param1:SInviteZazenInfo) : void
        {
            var _loc_3:InviteZazenInfoTime = null;
            var _loc_2:int = 0;
            while (_loc_2 < this._invitArray.length)
            {
                
                _loc_3 = this._invitArray[_loc_2] as InviteZazenInfoTime;
                if (EntityUtil.equal(_loc_3.inviteInfo.toEntityId, param1.toEntityId) && EntityUtil.equal(_loc_3.inviteInfo.playerInfo.entityId, param1.playerInfo.entityId))
                {
                    _loc_3.resetTime();
                    return;
                }
                _loc_2++;
            }
            this._invitArray.push(new InviteZazenInfoTime(param1));
            if (this._invitArray.length == 1)
            {
                this.show();
            }
            setLabel(this._invitArray.length);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._invitArray.length = 0;
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:InviteZazenInfoTime = null;
            super.clickHandler(event);
            if (this._invitArray.length > 0)
            {
                _loc_2 = this._invitArray.shift();
                Dispatcher.dispatchEvent(new DataEvent(EventName.ZazenProcessInviteInfo, _loc_2));
                setLabel(this._invitArray.length);
            }
            if (this._invitArray.length <= 0)
            {
                this.hide();
            }
            return;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

        public static function get instance() : ZazenInviteicon
        {
            if (!_instance)
            {
                _instance = new ZazenInviteicon;
            }
            return _instance;
        }// end function

    }
}
